import 'package:number_spark_flutter/style/ns_style.dart';
import 'package:number_spark_flutter/widgets/brick/ns_brick.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'ns_login_logic.dart';

class NSLoginPage extends StatelessWidget {
  NSLoginPage({Key? key}) : super(key: key);

  final logic = Get.put(NSLoginLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        alignment: Alignment.topCenter,
        children: [
          const NSImage(
            assetImage: 'img_bg_splash.png',
            fit: BoxFit.cover,
            width: double.infinity,
            height: double.infinity,
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              NSRow(
                mainAxisAlignment: MainAxisAlignment.center,
                margin: EdgeInsets.only(top: 516.h),
                children: [
                  NSImage(
                    assetImage: 'img_fast_login.png',
                    width: 145.w,
                    onTap: () {
                      logic.doClickFastLogin();
                    },
                  ),
                  NSImage(
                    assetImage: 'img_apple_login.png',
                    width: 145.w,
                    onTap: () {
                      logic.doClickAppleLogin();
                    },
                  )
                ],
              ),
              Expanded(child: Container()),
              NSRow(
                margin: EdgeInsets.only(bottom: ScreenUtil().bottomBarHeight + 20.h, left: 60.w, right: 60.w),
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  GetBuilder<NSLoginLogic>(builder: (logic) {
                    return NSImage(
                      margin: EdgeInsets.only(right: 10.w),
                      assetImage: logic.agreePrivateStatus ? 'icon_select.png' : 'icon_select_nor.png',
                      width: 20.w,
                      onTap: () {
                        logic.doClickSelect();
                      },
                    );
                  }),
                  Expanded(
                    child: RichText(
                        maxLines: 2,
                        text: TextSpan(children: [
                          TextSpan(
                            text: 'By using our App you agree with our',
                            style: TextStyle(
                              fontSize: 12.sp,
                              color: Colors.white,
                              fontFamily: 'Modak-Regular'
                            ),
                          ),
                          TextSpan(
                            text: ' Terms of Use',
                            style: TextStyle(
                              fontSize: 12.sp,
                              color: kAppColor('#4AF6FE'),
                              decoration: TextDecoration.underline,
                            ),
                            recognizer: TapGestureRecognizer()
                              ..onTap = () {
                                logic.doClickTermsOfUser();
                              },
                          ),
                          TextSpan(
                            text: ' and ',
                            style: TextStyle(
                              fontSize: 12.sp,
                              color: Colors.white,
                            ),
                          ),
                          TextSpan(
                            text: ' Privacy Policy. ',
                            style: TextStyle(
                              fontSize: 12.sp,
                              color: kAppColor('#4AF6FE'),
                              decoration: TextDecoration.underline,
                            ),
                            recognizer: TapGestureRecognizer()
                              ..onTap = () {
                                logic.doClickPrivacyPolicy();
                              },
                          )
                        ])),
                  ),
                ],
              )
            ],
          )
        ],
      ),
    );
  }
}
